package com.itheima.reggie.mappers;

import com.itheima.reggie.entity.Category;
import com.itheima.reggie.entity.R;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CategoryMapper {
    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    @Select("select * from category")
    List<Category> findAll();

    @Delete("delete from category where id=#{id}")
    void delete(Long id);

    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    void update(Category category);

    // @Select("select * from category where type=#{type}")
    List<Category> list(Integer type);

    @Select("select * from category where id=#{id}")
    Category findById(Long categoryId);
}
